//
//  PlaceCell.m
//  ChatKit-OC
//
//  Created by th on 2017/3/26.
//  Copyright © 2017年 ElonChan. All rights reserved.
//

#import "PlaceCell.h"

@interface PlaceCell()


@property (nonatomic, strong) YYLabel *titleLabel;

@end

@implementation PlaceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellWithTalbeView:(UITableView *)tableView {
    
    PlaceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"palceCellID"];
    
    // Configure the cell...
    
    if (!cell) {
        cell = [[PlaceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"palceCellID"];
    }
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    for (UIView *view in self.subviews) {
        if([view isKindOfClass:[UIScrollView class]]) {
            ((UIScrollView *)view).delaysContentTouches = NO; // Remove touch delay for iOS 7
            break;
        }
    }
    
    self.backgroundView.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    
    [self setupUI];
    
    return self;
}

- (void)setupUI {
    
    _titleLabel = [YYLabel new];
    
    _titleLabel.ignoreCommonProperties = YES;
    
    _titleLabel.displaysAsynchronously = YES;
    
    [self.contentView addSubview:_titleLabel];
}


- (void)setModel:(PlaceModel *)model {
    _model = model;
    
    _titleLabel.origin = CGPointMake(kSpaceX, 10);
    
    _titleLabel.size = model.layout.textBoundingSize;
    
    _titleLabel.textLayout = model.layout;
    
     UIView *line = [[UIView alloc] initWithFrame:CGRectMake(kSpaceX, _titleLabel.maxY_pro+9.5, kMainWidth - kSpaceX*2, 0.5)];
    line.backgroundColor = kLineColor;
    
    [self.contentView addSubview:line];
}


@end
